import service from "@/utils/request";

/**
 * 根据当前登录人权限 获取组织树
 * */
export const deptTree = (params?: Object) => {
  return service({
    url: '/admin/dept/tree',
    method: 'get',
    params,
  });
};

/**
 * 分级加载租户下的组织
 * @param params 
 * @returns 
 */
export const getDeptTreeParent = (params?: Object) => {
  return service({
    url: '/admin/dept/parent',
    method: 'get',
    params,
  });
};

/**
 * 根据当前登录人权限 获取角色列表
 * */
export const getRoleListAPI = (params?: Object) => {
  return service({
    url: '/admin/role/listRolesByShowType',
    method: 'get',
    params,
  });
};

/**
 * 根据当前登录人权限 获取岗位列表
 * */
export const getPostListAPI = (params?: Object) => {
  return service({
    url: '/admin/post/list',
    method: 'get',
    params,
  });
};

/**
 * 获取相对目标关系list
 * */
export const getRelativeRelationListAPI = (params?: Object) => {
  return service({
    url: '/admin/relativeRelation/findRelativeTarget',
    method: 'get',
    params,
  });
};

/**
 * 获取相对目标关系list
 * */
export const getFindRelativeRangeListAPI = (params?: Object) => {
  return service({
    url: '/admin/relativeRelation/findRelativeRange',
    method: 'get',
    params,
  });
};


/**
 * 根据当前登录人权限 获取用户可见分组
 * */
export const getGroupListAPI = (params?: Object) => {
  return service({
    url: '/admin/sysGroup/listUserVisiblePage',
    method: 'get',
    params,
  });
};

/**
 * 获取分组下人员列表
 * */
export const getUserByGroupIdAPI = (groupId, params) => {
  return service({
    url: `/admin/sysGroup/getUserByGroupId/${groupId}`,
    method: 'get',
    params,
  });
};

/**
 * 获取组织列表 一维数组
 * @returns 
 */
export const getDeptList = () => {
  return service({
    url: '/admin/dept/list',
    method: 'get'
  });
};

/**
 * 获取节点下人员列表
 * */
export const getPersonListAPI = (params?: Object) => {
  return service({
    url: '/admin/user/getUserPageAll',
    method: 'get',
    params,
  });
};

/**
 * 获取角色节点下人员列表
 * */
export const getRoleUserListAPI = (params?: Object) => {
  return service({
    url: '/admin/user/role/page',
    method: 'get',
    params,
  });
};

/**
 * 根据岗位查询人员
 * */
export const getPostUserListAPI = (params?: Object) => {
  return service({
    url: '/admin/user/post/page',
    method: 'get',
    params,
  });
};

/**
 * 批量用户ID列表获取用户信息
 * */
export const getUserInfoByUserIdsAPI = (data?: Object) => {
  return service({
    url: `/admin/user/getUserInfoByUserIds`,
    method: 'post',
    data,
    headers: {
      'Content-Type': "application/json;charset=UTF-8"
    },
  });
};

/**
 * 获取抄送自定义列表
 * */
export const carbonCopylist = () => {
  return service({
    url: '/document/carbonCopy/list',
    method: 'get',
  });
};

/**
 * 获取传阅组列表
 * */
export const getCirculationListAPI = (data?: Object) => {
  return service({
    url: '/circulate/circulate/listGroup',
    method: 'post',
    data,
  });
};

/**
 * 获取传阅组下人员列表
 * */
export const getCirculationUserAPI = (data?: Object) => {
  return service({
    url: `/circulate/circulate/getGroupAndUserByGroupId`,
    method: 'post',
    data,
  });
};

/**
 * 获取跨租户用户列表
 * */
export const getNoTenantUserPageAPI = (params?: Object) => {
  return service({
    url: '/circulate/circulate/getUserPageAll',
    method: 'get',
    params,
  });
};

/**
 * 查询跨租户用户ID列表获取用户信息
 * */
export const getNoTenantUserInfoByIdsAPI = (data?: Object) => {
  return service({
    url: `/admin/noTenant/getUserInfoByUserIds`,
    method: 'post',
    data,
    headers: {
      'Content-Type': "application/json;charset=UTF-8"
    },
  });
};